#include<iostream>
#include<map>
using namespace std;
int main()
{
	int a, b;
	int day[7] = { 0 };
	int i = 0,mark=0,marktime=0;
	bool flag = 0;
	while (cin >> a >> b)
	{
		day[i++] = a + b;
	}
	map<int, int> mp;
	for (i = 0; i < 7; ++i)
	{
		mp[i] = day[i];
		if (day[i] > 8)
			flag = 1;

		if (flag && day[i] > marktime)
		{
			marktime = day[i];
			mark = i + 1;
		}
	}

	if (!flag)
		printf("0");
	else
		printf("%d", mark);
	return 0;
}